package com.lagou;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;

@SpringBootApplication
@EnableDiscoveryClient
public class GatewayApplication {

    public static void main(String[] args) {
        SpringApplication.run(GatewayApplication.class, args);
    }


    //开启cachedRequestBodyObject，暂时不知道如何在yml中配置把body放入到缓存中 已这种方式开启
    //不理解配置一个就相当于开启cachedRequestBodyObject 其他配置在yml就可以
   /* @Bean
    public RouteLocator tpauditRoutes(RouteLocatorBuilder builder) {
        return builder.routes()
                .route(r -> r
                        .readBody(String.class, requestBody -> {
                            //log.info("requestBody is {}", requestBody);
                            // 这里 r.readBody做了一个前置语言，这样就可以在filter中通过exchange.getAttribute("cachedRequestBodyObject"); 获取body体
                            return true;
                        }).and()
                        .path("/w/**")
                        .filters(f -> f.stripPrefix(1)
                                .hystrix(h -> h.setName("Hystrix").setFallbackUri("forward:/timeoutfallback")))
                        .uri("lb://ADMIN/")
                )

                .build();
    }*/


}
